import fetch from "@/utils/http";
import { queryToString } from "@/utils/utils";
import { AddNews, EditNews, NewsResponse } from "./news";
/**
 * 获取新闻列表
 */
export function getNewsList(query: {
  pageNum: number;
  pageSize: number;
  createBy?: string;
}) {
  return fetch<NewsResponse>(
    `/system/notice/list?${queryToString(query)}`,
    "MANGMENT",
    {
      method: "get"
    }
  );
}
/**
 * 删除新闻
 */
export function delNotice(id: number) {
  return fetch(`/system/notice/${id}`, "MANGMENT", {
    method: "DELETE"
  });
}
/**
 * 添加新闻
 */
export function addNews(data: AddNews) {
  return fetch("/system/notice", "MANGMENT", {
    method: "POST",
    body: JSON.stringify(data)
  });
}
/**
 * 编辑新闻
 */
export function editNews(data: EditNews) {
  return fetch("/system/notice", "MANGMENT", {
    method: "PUT",
    body: JSON.stringify(data)
  });
}
